package Code;

/**
 * @Author zqc
 * @Date 2020/11/19-21:24
 * @Description 结点类：实现Comparable接口，重写compareTo方法，使之可排序
 */
public class Node implements Comparable<Node>{
    Byte data;      //数值-可以为空，故用封装类型
    int weight;     //权值
    Node left;
    Node right;

    public Node(Byte data,int weight){
        this.data = data;
        this.weight = weight;
    }


    @Override
    public int compareTo(Node o) {      //倒序排序
        return o.weight-this.weight;
    }

    @Override
    public String toString() {
        return "Node{" +
                "data=" + data +
                ", weight=" + weight +
                ", left=" + left +
                ", right=" + right +
                '}';
    }

}
